﻿using System.Collections.Generic;
using System.Linq;
using ControleRepresentante.Logic.Models;

namespace WebSite.Controllers.PrintTemplates
{
    public interface IPrintTemplateSelector
    {
        IPrintTemplate GetPrintTemplate(Representante representante, Pedido pedido);
    }

    public class PrintTemplateSelector : IPrintTemplateSelector
    {
        private readonly List<IPrintTemplate> m_Templates;

        public PrintTemplateSelector()
        {
            m_Templates = new List<IPrintTemplate>
            {
                new JolitexPrintTemplate(),
                new TriviumPrintTemplate(),
                new DefaultPrintTemplate(),
            };
        }

        public IPrintTemplate GetPrintTemplate(Representante representante, Pedido pedido)
        {
            return m_Templates.First(x => x.CanHandle(representante, pedido));
        }
    }
}